package com.yangzheandroid.rxmvp.presenter.login;


import com.yangzheandroid.rxmvp.base.RxPresenter;
import com.yangzheandroid.rxmvp.view.activity.login.LoginContract;
import com.yangzheandroid.rxmvp.what.login.UserManager;

import javax.inject.Inject;

/**
 * Author：Jalen on 2016/7/17 11:19
 * Contact: studylifetime@sina.com
 */
public class LoginPresenter extends RxPresenter<LoginContract.View> implements LoginContract.Presenter {
    private static final String TAG = LoginPresenter.class.getSimpleName();

    @Inject
    public LoginPresenter() {

    }
    public UserManager mUserManager = new UserManager();
    @Override
    public void isLoginSuccess() {
//        Subscription subscribe = HttpClients.subscribe(HttpClients.apiStore().login(mView.getUserName(), mView.getUserPsd()), new DefaultSubscriber<UserBean>() {
//            @Override
//            public void onNext(UserBean userBean) {
//                ToastUtils.showToast("登录成功");
//            }
//        });
//        addSubscription(subscribe);
        String username=mView.getUserName();
        String password=mView.getUserPsd();
        if (username == null || username.length() == 0) return;
        if (password == null || password.length() < 6) return;

        mUserManager.performLogin(username, password);

    }

    public void setUserManager(UserManager userManager) {
        mUserManager = userManager;
    }
}
